package exception;

import java.io.IOException;

public class ThrowDemo {
    public static void main(String[] args)  {

//        Test test = new Test();
//        try {
////            test.setAge(200);
//            test.setAge(2000);
//            System.out.println(test.getAge());
//        }catch (Exception e){
//            System.out.println("输入不合法");
//        }

        Test test1 = new Test();

        try {
            test1.setAge(120);
        } catch (ExceptionOfIllegalAge e) {
//            throw new RuntimeException(e);//打印错误堆栈信息;
            System.out.println(e.getMessage());//输出错误信息并输出
        }

        System.out.println(test1.getAge());
        /**没try catch*/

    }
}
